#include "analogy_rules_searcher.hpp"

namespace mashine { namespace kb { namespace search {

/**
 * create visitor that search facts with specified name
 * by default name = * (select all facts)
 */
AnalogyRulesSearchVisitor::AnalogyRulesSearchVisitor(std::string name)
		: SearchVisitor<mashine::kb::Rule, std::string>(name)
{

}

/**
 * get array of facts selected from kBase
 */
std::vector<mashine::kb::Rule> AnalogyRulesSearchVisitor::search(mashine::kb::KnowledgeBase * kBase)
{	
	if (criteria.compare("*"))
	{
		return kBase->getRules();
	}
		
	std::vector<mashine::kb::Rule> result;
	
	std::vector<mashine::kb::Rule>::const_iterator i;
	for (i = kBase->getRules().begin(); i != kBase->getRules().end(); ++i)
	{
		if ( criteria.compare((*i).getUndeniableLiteral()->getName()) )
		{
			result.push_back(*i);
		}
	}

	return result;
}

}}}
